<template>
  <div class="info">
    <h3>{{ goodsName }}</h3>
    <p class="price">
      价格:<span>{{ '¥' + price }}</span>
    </p>
    <ul>
      <li v-for="d in des" :key="d">{{ d }}</li>
    </ul>
    <p class="address">
      配送至<input type="text" />{{ store > 0 ? '有货' : '无货' }}
    </p>
    <div class="box">
      <div class="select" v-if="catSpecList[0]">
        <p>{{ catSpecList[0].specName }}</p>
        <!-- 1111111111111111111111111111111111111111111111111111111111111111111111 -->
        <img
          :src="firstImg"
          :alt="s.value"
          v-for="s in catSpecList[0].specValueList"
          :key="s.valueId"
        />
      </div>
      <div class="select" v-if="catSpecList[1]">
        <p>{{ catSpecList[1].specName }}</p>
        <span
          v-for="s in catSpecList[1].specValueList"
          :key="s.valueId"
          class="value"
        >
          {{ s.value }}
        </span>
      </div>
      <div class="select">
        <p>数量</p>
        <div class="num">
          <button>-</button>
          <input type="num" />
          <button>+</button>
        </div>
      </div>
      <div class="select">
        <p>已选商品</p>
        <span class="buy">{{ buy.color }}+{{ buy.GB }}</span>
      </div>
      <div class="btn">
        <button class="btn1">立即购买</button>
        <button class="btn2">加入购物车</button>
        <span>
          <img
            src=""
            alt=""
          />
          在线客服
        </span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  mounted() {
    // console.log(this.specPicList[0].specValueId)
    // console.log(this.catSpecList[0].specValueList)
  },
  props: ['goods', 'store', 'catSpecList', 'specPicList'],
  data() {
    return {
      goodsName: this.goods.goodsName,
      price: this.goods.price,
      description: this.goods.description,
      firstImg: this.goods.picList[0].picUrl,
      buy: { color: '银调', GB: '16+1TB' }
    }
  },
  computed: {
    des() {
      return this.description.split('\n')
    }
  }
}
</script>

<style scoped>
.info {
  width: 650px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  /* border: 1px solid #000; */
}
.info .price {
  margin: auto 0;
  background-color: rgb(240, 240, 240);
}
.info .price span {
  margin-left: 20px;
  color: red;
  font-size: 30px;
}
li {
  list-style: none;
}
p.address {
  /* text-align: center; */
  padding: 10px;
  border-bottom: 1px solid #c2bfbf;
  /* border: 1px solid #000; */
}
.box {
  display: flex;
  flex-direction: column;
  /* border: 1px solid #000; */
}
.box .select {
  display: flex;
  align-items: center;
  line-height: 30px;
  /* border: 1px solid #000; */
}
.box .select p {
  margin-right: 20px;
  /* border: 1px solid #000; */
}
.box .select img {
  width: 50px;
  margin: 0 10px;
  border: 1px solid #000;
}
.box .select span.value {
  margin: 0 10px;
  padding: 5px;
  line-height: 35px;
  border: 1px solid #000;
}
.box .select span.buy {
  line-height: 50px;
  /* border: 1px solid #000; */
}
.box .btn {
  line-height: 50px;
  display: flex;
  gap: 20px;
  align-items: center;
  /* border: 1px solid #000; */
}
.box .btn button,
.box .btn span {
  width: 150px;
  height: 50px;
  line-height: 50px;
}
.box .btn button {
  color: white;
  font-size: 18px;
  border: 0px solid #000;
}
.box .btn button.btn1 {
  background-color: #ff531b;
}
.box .btn button.btn2 {
  background-color: #0099a8;
}
.box .btn span {
  text-align: center;
  vertical-align: middle;
  border: 1px solid #0099a8;
}
.box .btn span img {
  width: 30px;
  vertical-align: middle;
  /* border: 1px solid #000; */
}
</style>
